package top.wenzz.manage.system.manage.entity;

import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import top.wenzz.commons.annotation.Edit;
import top.wenzz.commons.annotation.Query;
import top.wenzz.commons.entity.DataEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;

/**
 * Created by 钟廷员 on 2016/9/13.
 */
@Entity( name = "sys_resources" )
@Data
public class SysResources extends DataEntity<SysResources> {
    @Column( length = 20, nullable = false )
    @Length( min = 2, max = 20, message = "资源名称长度为2-20" )
    @NotBlank( message = "资源名称不能为空" )
    @Edit("资源名称")
    @Query(Query.ReadType.LIKE)
    private String name;

    @Column(name="url", length = 255, nullable = false)
    @Length(min = 2, max = 255, message = "资源地址长度为2-255")
    @NotBlank(message = "资源地址不能为空")
    @Edit("资源地址")
    private String url;

    @ManyToOne
    @NotNull(message = "模块不能为空")
    @Edit(value = "模块")
    @Query
    @JoinColumn(name="module_id")
    private SysModule module;

}
